#!/usr/bin/env python 
# -*- coding:utf-8 -*-
"""
@Time:2022/3/5 下午2:53"
@Author:lydia_liu"
@File:product_launch_page.py
@function:
"""
from selenium.webdriver.common.by import By
from litemallPrac.page.base_page import BasePage
from litemallPrac.page.product_list_page import ProductListPage


class ProductLaunchPage(BasePage):
    _product_num = (By.XPATH,'//*[@for="goodsSn"]/..//input','123')
    _product_name = (By.XPATH, '//*[@for="name"]/..//input','商品名称0306')
    _remai = (By.XPATH,'//span[contains(text(),"热卖")]/..//span')
    _button_shangjia = (By.XPATH,'//div[@class="op-container"]/button[2]')

    def addproduct(self):

        #在添加上架商品页面，输入商品编号
        self.sendkeys(*self._product_num)
        #输入商品名称
        self.sendkeys(*self._product_name)
        #点击单选框：热卖
        self.on_click(*self._remai)
        #滑动到底部
        self.driver.execute_script('window.scrollTo(0, document.body.scrollHeight)')
        #点击上架按钮
        self.on_click(*self._button_shangjia)
        return ProductListPage(self.driver)